<template>
	<!-- 支付页面 -->
	<!-- 微信支付 -->
	<!-- 支付宝支付 -->
	<!-- 线下支付 -->
	<view class="app">
		<view class="price-box">
			<text>支付金额</text>
			<text class="price">{{money}}</text>
		</view>

		<view class="pay-type-list">

			<view class="type-item b-b" @click="changePayType(1)">
				<image src="../../static/Payment/Wechatpayment.png" style="width: 60rpx; height: 60rpx;"></image>
				<view class="con">
					<text class="tit" style="margin-left: 50rpx;">微信支付</text>
					<text style="margin-left: 50rpx;">推荐使用微信支付</text>
				</view>
				<label class="radio">
					<radio value="" color="#fa436a" :checked='payType == 1' />
					</radio>
				</label>
			</view>
			<view class="type-item b-b" @click="changePayType(2)">
				<image src="../../static/Payment/Alipay.png" style="width: 60rpx; height: 60rpx;"></image>
				<view class="con">
					<text class="tit" style="margin-left: 50rpx;">支付宝支付(敬请期待)</text>
				</view>
				<label class="radio">
					<radio value="" color="#fa436a" disabled/>
					</radio>
				</label>
			</view>
			<view class="type-item" @click="changePayType(3)">
				<image src="../../static/Payment/Offlinepayment.png" style="width: 60rpx; height: 60rpx;"></image>
				<view class="con">
					<text class="tit" style="margin-left: 50rpx;">线下支付(到付)</text>
				</view>
				<label class="radio">
					<radio value="" color="#fa436a" :checked='payType == 2' />
					</radio>
				</label>
			</view>
		</view>
		
		<text class="mix-btn" @click="confirm">确认支付</text>
	</view>
</template>

<script>

	export default {
		data() {
			return {
				payType: 1,
				orderInfo: {},
				money : 0,
				id:''
			};
		},
		onLoad(options) {
			if (options.mninr != null) {
				this.id = options.mninr
				this.money = options.mon
			} else{
				console.log(options)
				this.money = options.order
				this.id = options.data
			}
		},
		onShow() {
			if (uni.getStorageSync('accessToken') == '') {
				uni.showModal({
					title: '登录提示',
					content: '您尚未登录，是否立即登录',
					success: function(res) {
						if (res.confirm) {
							uni.navigateTo({
								url: '../long/long'
							})
							return
						} else if (res.cancel) {
							// 用户点击取消
						}
					}
				});
			}
		},
		methods: {
			//选择支付方式
			changePayType(type) {
				this.payType = type;
			},
			//确认支付
			confirm: async function() {
				uni.request({
					url:`http://192.168.1.54:8081/m.api`,
					method:'GET', 
					data:{
						"_gp":"order",
						"_mt":"offlinePrepay",
						"orderNo":this.id
					},
					header:{
						'accesstoken': uni.getStorageSync('accessToken')
					},
					success: (res) => {
						console.log(res)
						if(res.data.errmsg == '成功'){
							console.log(this.id)
							uni.redirectTo({
								url: '/pages/payment/success'
							})
						}
					}
				})
			},
		}
	}
</script>

<style scoped="scoped">
	.app {width: 100%;}
	.price-box {background-color: #fff;height: 265rpx;display: flex;flex-direction: column;justify-content: center;align-items: center;font-size: 28upx;color: #909399;}
	.price-box .price{font-size: 50rpx;color: #303133;margin-top: 12rpx;}
	.price-box .price:before{content: '￥';font-size: 40rpx;}
	.pay-type-list {margin-top: 20rpx;background-color: #fff;padding-left: 60rpx;}
	.pay-type-list .type-item{height: 120rpx;padding: 20rpx 0;display: flex;justify-content: space-between;align-items: center;padding-right: 60rpx;font-size: 30rpx;position:relative;}
	.pay-type-list .icon-zhifu {color: #fe8e2e;}
	.pay-type-list .icon-weixinzhifu {color: #36cb59;}
	.pay-type-list .tit{font-size: 30rpx;color: #303133;margin-bottom: 2rpx;}
	.pay-type-list .con{flex: 1;display: flex;flex-direction: column;font-size: 22rpx;color: #909399;}
	.mix-btn {display: flex;align-items: center;justify-content: center;width: 630rpx;height: 80rpx;margin: 80rpx auto 30rpx;font-size: 30rpx;color: #fff;background-color: #fa436a;
	border-radius: 10rpx;box-shadow: 1px 2px 5px rgba(219, 63, 96, 0.4);}

</style>
